{{!

  Copyright (c) Facebook, Inc. and its affiliates.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

}}
{{> AutoGenerated}}

package {{enum:javaPackage}};

import com.facebook.swift.codec.*;

@SwiftGenerated
public {{#enum:skipEnumNameMap?}}class{{/enum:skipEnumNameMap?}}{{^enum:skipEnumNameMap?}}enum{{/enum:skipEnumNameMap?}} {{enum:javaCapitalName}}{{#enum:skipEnumNameMap?}} extends IntEnum{{/enum:skipEnumNameMap?}} {
{{^enum:skipEnumNameMap?}}
{{#enum:values}}
    {{enum_value:javaConstantName}}({{enum_value:value}}){{^last?}},{{/last?}}{{#last?}};{{/last?}}
{{/enum:values}}
{{! semicolon here is required for Java Enum definition, see Java Language Spec
    section 8.9.1 https://docs.oracle.com/javase/specs/jls/se8/html/jls-8.html#jls-8.9.1}}
{{^enum:values}}
    ;
{{/enum:values}}
{{/enum:skipEnumNameMap?}}

    private final int value;

    {{enum:javaCapitalName}}(int value) {
        this.value = value;
    }

    {{#enum:skipEnumNameMap?}}
    @java.lang.Override
    {{/enum:skipEnumNameMap?}}
    @ThriftEnumValue
    public int getValue() {
        return value;
    }

    {{#enum:skipEnumNameMap?}}
    @ThriftIntEnumResolver
    {{/enum:skipEnumNameMap?}}
    public static {{enum:javaCapitalName}} fromInteger(int n) {
        {{^enum:skipEnumNameMap?}}
        switch (n) {
        {{#enum:values}}
        case {{enum_value:value}}:
            return {{enum_value:javaConstantName}};
        {{/enum:values}}
        default:
            return null;
        }
        {{/enum:skipEnumNameMap?}}
        {{#enum:skipEnumNameMap?}}
        return new {{enum:javaCapitalName}}(n);
        {{/enum:skipEnumNameMap?}}
    }
{{#enum:skipEnumNameMap?}}

    @java.lang.Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        {{enum:javaCapitalName}} other = ({{enum:javaCapitalName}})o;

        return this.value == other.value;
    }

    @java.lang.Override
    public int hashCode() {
        return value;
    }
{{/enum:skipEnumNameMap?}}
}
